home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 2 / Macwelt DVD 2.cdr / HTML-Tools / macos9 / XML Tools 2.4 / Examples / Save:Restore Desktop / Save Desktop / Save Desktop.rsrc / TEXT_2000_Source Text.txt < prev    next >
Encoding:
Text File  |  2000-08-13  |  1.0 KB  |  42 lines

  1. --
  2. --    Run this script to record the locations of all icons on your desktop.  Once recorded, 
  3. --    you can use the Restore Desktop script to restore all icons to their original positions.
  4. --
  5.  
  6. on writeFile(theFile, theData)
  7.     local fileRef
  8.     
  9.     set fileRef to open for access theFile with write permission
  10.     try
  11.         set eof fileRef to 0
  12.         write theData to fileRef
  13.         close access fileRef
  14.     on error errMsg number errNum
  15.         close access fileRef
  16.         error errMsg number errNum
  17.     end try
  18. end writeFile
  19.  
  20. on saveDesktop()
  21.     local outFile, theXML
  22.     
  23.     set outFile to new file
  24.     
  25.     set theXML to {"<desktop>" & return}
  26.     tell application "Finder"
  27.         repeat with anItem in items of desktop
  28.             if class of anItem is not disk then
  29.                 set thePosition to position of anItem
  30.                 set end of theXML to (tab & "<item name=\"" & ¬¨
  31.                     (name of anItem) & "\" h=\"" & ¬¨
  32.                     (item 1 of thePosition) & "\" v=\"" & ¬¨
  33.                     (item 2 of thePosition) & "\"/>" & return)
  34.             end if
  35.         end repeat
  36.     end tell
  37.     set end of theXML to ("</desktop>" & return)
  38.     
  39.     writeFile(outFile, theXML as string)
  40. end saveDesktop
  41.  
  42. saveDesktop()